home *** CD-ROM | disk | FTP | other *** search
- /*
- *
- * XCMDTools.c
- *
- * Routines pour faciliter la gestion des XCMD
- *
- * 14/11/90 - Création - EG -
- *
- */
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <exec/ports.h>
- #include <clib/exec_protos.h>
- #include <clib/alib_protos.h>
- #include <stdio.h>
- #include "XCMD.h"
- #include "XCMDTools.h"
-
-
- /*
- * CreateXCMD()
- *
- * Création une XCMD. La mémoire est allouée. Elle devra
- * être libéree par un DeleteXCMD. Le port passé en paramètre
- * est celui du processus externe, c'est à dire celui qui recevra
- * les réponses de Term.
- *
- */
- struct XCMD *CreateXCMD(struct MsgPort *port)
- {
- struct XCMD *xcmd = AllocMem(sizeof(struct XCMD),MEMF_PUBLIC|MEMF_CLEAR);
- if(xcmd)
- {
- xcmd->xcmd_Message.mn_Length = sizeof(struct XCMD);
- xcmd->xcmd_Message.mn_ReplyPort = port;
- }
- return(xcmd);
- }
-
-
- /*
- * DeleteXCMD()
- *
- * Détruit une XCMD. Libère la mémoire allouée à la création.
- *
- */
- void DeleteXCMD(struct XCMD *xcmd)
- {
- FreeMem(xcmd,sizeof(struct XCMD));
- }
-
-
- /*
- * SendXCMD()
- *
- * Envoie une commande vers Term II. Retourne TRUE si
- * la XCMD a pu être envoyée, FALSE sinon.
- *
- */
- BOOL SendXCMD(struct XCMD *xcmd)
- {
- BOOL sent = FALSE;
- struct MsgPort *TermPort;
- Forbid() ;
- if(TermPort = FindPort("XTERM"))
- {
- PutMsg(TermPort,xcmd);
- sent = TRUE;
- }
- Permit();
- return(sent);
- }
-
-